package test.orm;

import java.util.List;

import org.apache.ibatis.session.SqlSession;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;

import web1.orm.mybatis2.mybatisFactory;
import web1.orm.mybatis2.pojo.Goods;

public class testMybatis2 {
	@Before
	public void setUp() throws Exception {
	}

	@After
	public void tearDown() throws Exception {
	}
    private final String classname="web1.mybatis2.GoodsMapper.";
    
	@Test
	public void selectAllGoods() {
		SqlSession sqlSession = mybatisFactory.getSqlSession();
	
//		int id = 1;
		Goods cur =sqlSession.selectOne(classname+"selectAllGoods");
		try {  
			if (cur != null) {
			System.out.println("selectByID:" + cur.getRemark());
		} 
		} finally {  
			sqlSession.close();  
	    }  
	}
	
	@Test
	public void selectRecommendGoods() {
		SqlSession sqlSession = mybatisFactory.getSqlSession();	
		String goodCode = "1";
		List<Goods> lis = sqlSession.selectList(classname+"selectRecommendGoods",goodCode); 
		if (!lis.isEmpty()) {
			System.out.println("selectsByName begin:");
			for (Goods cur : lis) {
				System.out.println( cur.getRemark());
			}
			System.out.println("selectsByName end:");
		}
	}
}
